package com.liu.pay.config;

import java.io.FileWriter;
import java.io.IOException;

public class AlipayConfig {

    // 应用ID,您的APPID，收款账号既是您的APPID对应支付宝账号,开发时使用沙箱提供的APPID，生产环境改成自己的APPID
    public static String APP_ID = "2021000117631117";

    // 商户私钥，您的PKCS8格式RSA2私钥(教程：https://opendocs.alipay.com/common/02kipl)
    public static String APP_PRIVATE_KEY = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC31qprix9fHUXL909wCnCCCT5UgZPufXSER+tMzspCUz895S8XoAOkWN+ANqi8NuyP4Zod+TFXxACJnbSh9Mkq8/bhYkh1/++YFT72HTWhsZyz7p8egzkmznIzxrvQ3+q9ajLHb5I8IdHtAaa3hrZwdYVcOoil/c/pwc9/kUFolJG5PuMs9ghXmpxprzpH4zJ/+Vgz5/s+ZzUNiXvp5RCh+lNohbESmi/bhpfNXinwsVb9AgJlkjb2Jm0IDMyCYtptrvw+FJSXAo8p5ojJVsoC8xh2NIX7aij2K4Q9aFe4Pkc325AQuVe8j5xHHmdx1VRDcCa5DHnTDjbAkm7B0+srAgMBAAECggEAWJRsxSjh0tit+tuNQTUmhOGjUOCmwPFeJSbqL7YsKs0l2dMGX+HQH25bMtIjd50XWzSfJ/YcWmeswqJkmOzzyWiH+o160LCjZ6pFDh2A7ApCsUg3D2K3NQWgbWZCtSBPYTk8gnA2DBdXqVV0WVXlrkZSHeBuW1zyw3WJX7RDyfmJfhlzVEADurqOcrh5WQcZ1CSuGRjoeJSKM0gn9Pcw5NQTIBBREF2pVx4RzNtS1JTXAyEJVnNndWMa6EPAOGyKG+zJiNGwy5ZzWKJwFLob47Xbzcgd60oTL0pBbvVJ4L5zGaqmVxO2w4xVb+xbvI/G5hGjT8S0tnhnvoiGtgxZcQKBgQD2mPZeeiJiLyVIah0LvM7bNnbIEbuKeh4IyNxnCsZ0vYMyk/qsDDLrrhfh/wXaAeytPy37HMK3loj19MxSG339Lt/kyrHstCg3uAirFI+zdliHvPRrXi7OPytGyZ3IzUKSGw8naedHKpZ7x6R174+O5KVDpEaoP9YsgCOZmDVi9QKBgQC+2Rz5ALDat5uZcq6BvYyoIqhW2hQsAhGJd3zBGhR10n4ZvmIehhj438oNKJkjO2GVbQSmYOoa7CbkHkWdLd0kY0hkPhjJ7L/bWgSULuozxJu8lb4nEjsXUbOXabdznRK7e8wZxgxGDKNU5iCwZyaYnxNy6zNKW8ZY1RyJldaBnwKBgQCXgJKcqNzHBcAaJVeDBpTwCR4g/QQDp9McAoumovAaePRJ9rBjU3tVYLg7mLq3nccTCWXuiVT4BfxPX/7H0ywsiMf1gLKfgm/TC7YHpbJDx8nMW0KvVEXdYOHts6DE5ZaovQcqZ9430upxUc6wxmWknMUMMblXVSD4ZiF5FBJ4oQKBgQCR2FN2yptcmcHUMzq+tT8fYlTpAoE13GLQfbqdyzNlkvWA8OgE0Y+V6Vd8VNEqhn+ddJGAIEHnTx6tZ6DlbB46Z5Dz4iyJa15238TuBSg/ZXlqVbjaHOmBeZNYG5bxSFD/a6ze6WWJxrCu+apzhHCPY8m2IZ2xro7WZg4H6rThmwKBgAXLBouZhWmboDOpl2tqz30PMukf1jUO70MFVRyA23lvaJtfA0wyLaIj+yH43CCJ1zLGsya9OS8KGoJD6a/+ItLE+oMOI/Ki8414iVZgnlOmrriILf9Wy1PJd1HoTrc/bbH+1mn8V+17gzyN93DLRdQw1mZPQxVnbItbDzyERoSC";

    // 支付宝公钥,查看地址：https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
    public static String ALIPAY_PUBLIC_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAkg+ryxiTUIzimmLwQnI/5YkEtmSD3IaWXLNnJPj0kNsAaS9lisA5556LvgSI0bDX30ezoIX1EtX4qLwSSHYNuXJN/VYyuCscFCJCHJAlmbiFHZxsHZC1H/FPxoIxf1lIvBvOSZh0yITJ2YPF3TfB+DF4WlCFOzBSY5dknaqc6dNj986cjClTIqGuq8ugsF1X02qv+a732HJ+Buujc1PlFpW4wW7aLM/I0OVdZQ8PKB53ZiThnE4l4JA2q0iZ/U7kw8E14RmgBeJn93qA6ubmikfDs4+lBVdCw0fVWI7ecTOWpZUPagmjfS/6QGZELGhl2ML1KZo3nwjP4GIp+yYaxwIDAQAB";

    // 服务器异步通知页面路径  需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
    public static String notify_url = "http://localhost:8080/alipay.trade.page.pay-JAVA-UTF-8/notify_url.jsp";

    // 页面跳转同步通知页面路径 需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问(其实就是支付成功后返回的页面)
    public static String return_url = "http://localhost:8080/alipay.trade.page.pay-JAVA-UTF-8/return_url.jsp";

    // 签名方式
    public static String sign_type = "RSA2";

    // 字符编码格式
    public static String CHARSET = "utf-8";

    // 支付宝网关，这是沙箱的网关
    public static String gatewayUrl = "https://openapi.alipaydev.com/gateway.do";

    // 支付宝网关
    public static String log_path = "C:\\";


//↑↑↑↑↑↑↑↑↑↑请在这里配置您的基本信息↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑

    /**
     * 写日志，方便测试（看网站需求，也可以改成把记录存入数据库）
     * @param sWord 要写入日志里的文本内容
     */
    public static void logResult(String sWord) {
        FileWriter writer = null;
        try {
            writer = new FileWriter(log_path + "alipay_log_" + System.currentTimeMillis()+".txt");
            writer.write(sWord);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
